
if not redstone.getInput("back") then
	os.startTimer(0.2)
end
local stopTimer = false

while true do
	event, param1, param2, param3 = os.pullEvent()
	
	if event == "redstone" then
		if not redstone.getInput("back") then
			print("Attacking")
			os.startTimer(0.2)
		else
			print("Not attacking")
			stopTimer = true
		end
	elseif event == "timer" then
		if not stopTimer then
			turtle.attack()
			os.startTimer(0.2)
		else
			stopTimer = false
		end
	end
end
